//登录相关控制器
app.controller("signin", function ($scope, $rootScope, serve, $http) {
	$rootScope.title = "登录"
  $scope.login = function() {
    var user = {
      name : $scope.inputName,
      password : $scope.inputPassword
    }
    $http.post("/api/signin",user)
          .then(function (data) {
            // layer.alert(data)
            console.log(data.data);
            $rootScope.token = data.data;
            serve.get("/api/signin")
              .then(function (user) {
                $rootScope.user = user;
                window.location.href = '/#/home';
              })
          }, function (err){
            $.toast("出错了");
          })
  }
})

app.controller("signup", function ($scope, $rootScope, serve, $http){
	$rootScope.title = "注册";
  $scope.logup = function() {
    var user = {
      name : $scope.inputName,
      password : $scope.inputPassword
    }
    $http.post("/api/signup",user)
          .then(function (data) {
            $.toast(data)
          }, function (err){
            $.toast("出错了");
          })
  }
})
app.controller("signout", function ($scope, $rootScope, serve){
	$rootScope.title = "登出";
  $scope.logout = function() {
    serve.get("/api/signout")
          .then(function (data) {
            $.toas(data)
          })
  }
})
